package test;

import static org.junit.Assert.*;
import game.Fleet;
import game.Game;
import game.GameBoard;
import org.junit.Test;

public class testLandOnFleet {
	
	public Game game = new Game();
	public Fleet fleet1 = (Fleet)GameBoard.fields[17];
	public Fleet fleet2 = (Fleet)GameBoard.fields[18];
	public Fleet fleet3 = (Fleet)GameBoard.fields[19];
	public Fleet fleet4 = (Fleet)GameBoard.fields[20];
	
	@Test
	public void TestLandOnFleet_Rent1() {
		game.createPlayers(2);
		
		// Sets player 1 to owner of ONE fleet
		fleet1.setOwner(game.getPlayer(0));
		
		int player2PointsAtStart = game.getPlayer(1).getAccount().getPoint();
		System.out.println("Player 2's points before land on fleet: " +player2PointsAtStart);
		fleet1.landOnField(game.getPlayer(1));
		System.out.println("Player 2's points after land on fleet: " + game.getPlayer(1).getAccount().getPoint());
		
		assertEquals(player2PointsAtStart-500, game.getPlayer(1).getAccount().getPoint());
	}
	
	@Test
	public void TestLandOnFleet_Rent2() {
		game.createPlayers(2);
		
		// Sets player 1 to owner of TWO fleet
		fleet1.setOwner(game.getPlayer(0));
		fleet2.setOwner(game.getPlayer(0));
		
		int player2PointsAtStart = game.getPlayer(1).getAccount().getPoint();
		System.out.println("Player 2's points before land on fleet: " +player2PointsAtStart);
		fleet1.landOnField(game.getPlayer(1));
		System.out.println("Player 2's points after land on fleet: " + game.getPlayer(1).getAccount().getPoint());
		
		assertEquals(player2PointsAtStart-1000, game.getPlayer(1).getAccount().getPoint());
	}
	
	@Test
	public void TestLandOnFleet_Rent3() {
		game.createPlayers(2);
		
		// Sets player 1 to owner of THREE fleet
		fleet1.setOwner(game.getPlayer(0));
		fleet2.setOwner(game.getPlayer(0));
		fleet3.setOwner(game.getPlayer(0));
		
		int player2PointsAtStart = game.getPlayer(1).getAccount().getPoint();
		System.out.println("Player 2's points before land on fleet: " +player2PointsAtStart);
		fleet1.landOnField(game.getPlayer(1));
		System.out.println("Player 2's points after land on fleet: " + game.getPlayer(1).getAccount().getPoint());
		
		assertEquals(player2PointsAtStart-2000, game.getPlayer(1).getAccount().getPoint());
	}
	
	@Test
	public void TestLandOnFleet_Rent4() {
		game.createPlayers(2);
		
		// Sets player 1 to owner of FOUR fleet
		fleet1.setOwner(game.getPlayer(0));
		fleet2.setOwner(game.getPlayer(0));
		fleet3.setOwner(game.getPlayer(0));
		fleet4.setOwner(game.getPlayer(0));
		
		int player2PointsAtStart = game.getPlayer(1).getAccount().getPoint();
		System.out.println("Player 2's points before land on fleet: " +player2PointsAtStart);
		fleet1.landOnField(game.getPlayer(1));
		System.out.println("Player 2's points after land on fleet: " + game.getPlayer(1).getAccount().getPoint());
		
		assertEquals(player2PointsAtStart-4000, game.getPlayer(1).getAccount().getPoint());
	}	
}